package com.googlecode.astoolkit.modules.title {

	import com.googlecode.astoolkit.utils.AbstractNode;
	import com.googlecode.astoolkit.utils.Sitemap;
	
	import flash.events.EventDispatcher;

	public class TitleModule extends EventDispatcher {

		public function TitleModule() {
			super();
		}

		// 
		public static function changePath(path:String, siteNameSeparator:String=" · ", pathNameSeparator:String=" / "):String {
			var pathIds:Array = Sitemap.getIdsArrayByPath(path);
			var title:String = "";
			var l:uint = pathIds.length;
			for(var i:uint = 0; i < l; i++) {
				var nodeLabel:String = AbstractNode(Sitemap.getNodeById(pathIds[i])).title;
				title += nodeLabel;
				if (i < l - 1) {
					title += pathNameSeparator;
				}
			}
			title += siteNameSeparator + " " + AbstractNode(Sitemap.getNodeById(0)).title;
			return title;
		}


	}

}